$(function(){

	var ww = $(window).width();//屏幕总宽度
	var dfw = $('#shop_list').width();
	var ofle = $('#shop_list').offset().left;//距离左边屏幕的宽度

	// 所要限制的宽度
	var result = dfw+ofle-5;



	$('#shop_list .list-f').mouseenter(function(){

		$(this).find('.overlay').show();
		var ifw = $(this).find('.overlay').offset().left;
		
		if(ifw>result){
			$(this).find('.overlay').css({"left":"-252px"});
		}
		
	});
	$('#shop_list .list-f').mouseleave(function(){
		$('#shop_list .list-f').find('.overlay').hide();
	});
	

	$('#shop_list .list-f .overlay').mouseenter(function(){
		var _this = $(this);

		setTimeout(function(){
			_this.hide();
		},800);
	});

	//登录框的效果

		$('#logout_user_info .login').click(function(){
			$('#screen').show();
		});

		$('.qx').click(function(){
			$('#screen').hide();
		});
		$('.username').focusin(function(){
			$(this).css({"border-color":"#488EE7"})
			$('.user-img').css({"background-position":"0 -108px"})
		});

		$('.username').focusout(function(){
			$(this).css({"border-color":"#ddd"})
			$('.user-img').css({"background-position":"0 -68px"})
		});

		$('.password').focusin(function(){
			$(this).css({"border-color":"#488EE7"})
			$('.password-img').css({"background-position":"0 -186px"})
		});

		$('.password').focusout(function(){
			$(this).css({"border-color":"#ddd"})
			$('.password-img').css({"background-position":"0 -147px"})
		});


		
	

		$('.filter-option li i').live('click',function(){
			var at = $(this).parent('li').attr('data-type');
			at += ',';
			
			var re =new RegExp(at);
			if(re.test(s))
			{	
				//如果存在则去掉
			    newStr = s.replace(new RegExp(at), "");
			}else{
				if(s != '0'){
					//如果不存在则链接
					newStr = s + at;
				}else{
					newStr = at;
				}
				
			}

			if(cnid){
				location.href = ACTION + '&s=' + newStr + '&cnid=' + cnid;
			}else{
				location.href = ACTION + '&s=' + newStr;
			}

			

			

		});



		

		


		$(".code").validate({
		// 验证规则
		 code: {
			 rule: {
			 required: true,
			 ajax: CONTROLLER+"/ajax_code"
			 },
		 error: {
			 required: " 验证码不能为空",
			 ajax: " 验证码输入错误"
		 },
		 message: " 请输入验证码",
		 success: " 输入正确"
		 }
		 });

		$(".username").validate({
		// 验证规则
		 username: {
			 rule: {
			 required: true,
			 ajax: CONTROLLER+"/ajax_user"
			 },
		 error: {
			 required: "用户名不能为空",
			 ajax: " 用户名不存在"
		 },
		 message: " 请输入用户名",
		 success: " 输入正确"
		 }
		 });


	
});

